﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities;

namespace AbpToDomain.EntityInfo
{
    public class Box:Entity
    {
        [Key]
        public Guid Id_Box { get; set; }
        public string BoxCode {  get; set; }
        [Comment("类型")]
        public string? Type {  get; set; }
        [Comment("宽")]
        public int Width { get; set; }
        [Comment("深")]
        public int DePth { get; set; }
        [Comment("高")]
        public int Height { get; set; }
        [Comment("格口数")]
        public int BoxGridQuantity { get; set; }    
        public DateTime CreateTime{ get; set; }
        public DateTime? UpdateTime { get; set;}
        [Comment("允许使用")]
        public bool IsEnable {  get; set; }
        [Comment("是否使用虚拟储位")]
        public bool VirtualSpace {  get; set; }
        public string? Info {  get; set; }
        public string? Remarks {  get; set; }
        public override object[] GetKeys()
        {
           return new object[] { Id_Box };
        }
        public Box()
        {
            CreateTime = DateTime.Now;
            IsEnable = true;
        }
        //foreignkey
        public WarehouseLine? WarehouseLine { get; set; }
        public InlethouseLine? InlethouseLine { get; set; }
        public Guid? Id_WarehouseLine { get; set; }
        public Guid? Id_InlethouseLine { get; set; }
        public List<BoxGrid>? BoxGrids { get; set; } = new List<BoxGrid>();
        public TaskOrder? TaskOrder { get; set; }
        //function
        public Box AddBox(string BoxCode, int BoxGridQuantity,int Width,int DePth,int Height,string Type,bool virtualSpace)
        {
            Box box = new Box();
            box.BoxCode = BoxCode;
            box.VirtualSpace = VirtualSpace;
            box.Width = Width;
            box.Height = Height;
            box.DePth = DePth;
            box.Type = Type;
            box.CreateTime = DateTime.Now;
            box.IsEnable = true;
            box.BoxGridQuantity = BoxGridQuantity;
            return box;


        }
    }
    public class BoxGrid : Entity
    {
        [Key]
        public Guid Id_BoxGrid { get; set; }
        [Comment("格口序号")]
        public int Sequence {  get; set; }
        [Comment("格口号")]
        public string BoxGridCode {  get; set; }
        [Comment("储位数")]
        public int BoxPositionQuantity { get; set; }
        public override object[] GetKeys()
        {
            return new object[] { Id_BoxGrid };
        }
        //foreginkey
        public Box TheBox { get; set; }   
        public MaterialBase? materialBase;
        //function
        public BoxGrid AddBoxGrid(int Sequence, string BoxGridCode,Box TheBox,int BoxPositionQuantity)
        {
            BoxGrid boxGrid = new BoxGrid();
            boxGrid.Sequence = Sequence;
            boxGrid.BoxGridCode = BoxGridCode;
            boxGrid.TheBox = TheBox;
            boxGrid.BoxPositionQuantity = BoxPositionQuantity;
            return boxGrid;
        }   
    }
    //public class BoxPosition : Entity
    //{
    //    [Key]
    //    public Guid Id_BoxPosition { get; set; }
    //    [Comment("储位号")]
    //    public string BoxPositionCode { get; set; }
    //    public DateTime? UpdateTime { get; set; }
    //    //foreginkey
    //    public BoxGrid TheBoxGrid { get; set; }
    //    public MaterialBase? MaterialBase { get; set; }
    //    public override object[] GetKeys()
    //    {
    //        return new object[] { Id_BoxPosition };
    //    }
    //    //function
    //    public BoxPosition AddBoxPosition(string BoxPositionCode,BoxGrid boxGrid)
    //    {
    //        BoxPosition boxPosition = new BoxPosition();
    //        boxPosition.BoxPositionCode = BoxPositionCode;
    //        boxPosition.TheBoxGrid = boxGrid;
    //        return boxPosition;
    //    }
    //}
}
